<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0021)http://192.168.1.105/ -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>WebSocket</title>
<script>

    function svc_connectPlatform() {
        //alert("");
        var wsServer = 'ws://'+window.location.host+':1818/';
        try {
            websocket = new WebSocket(wsServer);
        } catch (evt) {
            console.log("new WebSocket error:" + evt.data);
            websocket = null;
            if (typeof(connCb) != "undefined" && connCb != null)
                connCb("-1", "connect error!");
            return;
        }
        //alert("");
        websocket.onopen    = onOpen;
        websocket.onclose   = onClose;
        websocket.onmessage = onMessage;
        websocket.onerror   = onError;
    }


    function onOpen(evt) {
        console.log("Connected to WebSocket server.");
    }


    function onClose(evt) {
        console.log("Disconnected");
    }


    function onMessage(evt) {
		var rxdata=document.getElementById("UartReadHexText_id");
		    rxdata.value= rxdata.value+evt.data;
    }


    function onError(evt) {
        console.log('Error occured: ' + evt.data);
    }


  
	
	function send(){
	var sendmsg=document.getElementById("Write_uart_data_text_id");
	if (websocket.readyState == WebSocket.OPEN) {
           websocket.send(sendmsg.value);
        }else {
            console.log("send failed. websocket not open. please check.");
        }
    }
	
	function Clear()
	{
	var hexValRead=document.getElementById("UartReadHexText_id");
	var asciiValRead=document.getElementById("Write_uart_data_text_id");
	hexValRead.value="";
	asciiValRead.value="";
    }
</script>
</head>

<body onload="svc_connectPlatform();">
<div>
	<p>Receive Data:</p>
	<textarea id="UartReadHexText_id" cols="64" rows="12" readonly="readonly"></textarea>
</div>

<div>
  <p>Send Data:  </p>
<p>
  <textarea name="Write_uart_data_text_id" cols="64" rows="12" id="Write_uart_data_text_id"></textarea>
</p>
<p>
  <input type="button" style="{width:120px;}" value="send data" onclick="send();" id="Uart_send_id">
  <input name="button" type="button" id="Uart_clear_id" onclick="Clear()" value="clear">

</p>
</div>



</body></html>